home *** CD-ROM | disk | FTP | other *** search
/ PC Plus SuperCD (UK) 1998 August / PC Plus SuperCD 50a Issue 142 (CD142a) (August 1998).iso / trial / demon / TURNPIKE.1 / CLASSES.ZIP / sun / NET / ProgressEntry.class (.txt) < prev    next >
Encoding:
Java Class File  |  1997-04-14  |  1.3 KB  |  77 lines

  1. package sun.net;
  2.  
  3. public class ProgressEntry {
  4.    public static final int HTML = 0;
  5.    public static final int IMAGE = 1;
  6.    public static final int CLASS = 2;
  7.    public static final int AUDIO = 3;
  8.    public static final int OTHER = 4;
  9.    public int need;
  10.    public int read;
  11.    public boolean connected = false;
  12.    public String label;
  13.    public int type;
  14.    public Object key;
  15.  
  16.    ProgressEntry(Object var1, String var2, String var3) {
  17.       this.key = var1;
  18.       this.label = var2;
  19.       this.type = 1;
  20.       this.setType(var2, var3);
  21.    }
  22.  
  23.    public void setType(String var1, String var2) {
  24.       this.type = 4;
  25.       if (var2 != null) {
  26.          if (var2.startsWith("image")) {
  27.             this.type = 1;
  28.          } else if (var2.startsWith("audio")) {
  29.             this.type = 3;
  30.          } else if (var2.equals("application/java-vm")) {
  31.             this.type = 2;
  32.          } else if (var2.startsWith("text/html")) {
  33.             this.type = 0;
  34.          }
  35.       }
  36.  
  37.       if (this.type == 4) {
  38.          if (var1.endsWith(".gif") || var1.endsWith(".xbm") || var1.endsWith(".jpeg") || var1.endsWith(".jpg") || var1.endsWith(".jfif")) {
  39.             this.type = 1;
  40.             return;
  41.          }
  42.  
  43.          if (var1.endsWith(".au")) {
  44.             this.type = 3;
  45.             return;
  46.          }
  47.  
  48.          if (var1.endsWith(".class")) {
  49.             this.type = 2;
  50.             return;
  51.          }
  52.  
  53.          if (var1.endsWith(".html") || var1.endsWith("/")) {
  54.             this.type = 0;
  55.          }
  56.       }
  57.  
  58.    }
  59.  
  60.    public void update(int var1, int var2) {
  61.       if (this.need == 0) {
  62.          this.need = var2;
  63.       }
  64.  
  65.       this.read = var1;
  66.    }
  67.  
  68.    public synchronized boolean connected() {
  69.       if (!this.connected) {
  70.          this.connected = true;
  71.          return false;
  72.       } else {
  73.          return true;
  74.       }
  75.    }
  76. }
  77.